package day.day7_21;

import java.util.Arrays;

public class Main {
    public int getValue(int[] gifts, int n) {
        Arrays.sort(gifts); // ctrl+q 当前方法的声明
        //Arrays.sort 为数组排序的操作
        int ans = gifts[n/2];
        int num = 0;
        for (int i = 0; i < gifts.length; i++) {
            if(gifts[i] == ans) {
                num++;
            }
        }
        return num <= n/2 ? 0 : ans;
    }
}